package com.example.canteen.converter;

import com.example.canteen.dao.Dish;
import com.example.canteen.dao.SetMeal;
import com.example.canteen.dto.SetMealDTO;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;

public class SetMealConverter {

    public static SetMealDTO convertSetMeal(SetMeal setMeal) {
        SetMealDTO setMealDTO = new SetMealDTO();
        if (setMeal.getCategory() != null) {
            setMealDTO.setCategoryDTO(CategoryConverter.convertCategory(setMeal.getCategory()));
        }
        setMealDTO.setId(setMeal.getId());
        setMealDTO.setName(setMeal.getName());
        setMealDTO.setCategoryName(setMeal.getCategory().getName());

        return setMealDTO;
    }

    public static SetMeal convertSetMeal(SetMealDTO setMealDTO) {
        SetMeal setMeal = new SetMeal();
        if (setMealDTO.getCategoryDTO() != null) {
            setMeal.setCategory(CategoryConverter.convertCategory(setMealDTO.getCategoryDTO()));
        }
        setMeal.setId(setMealDTO.getId());
        setMeal.setName(setMealDTO.getName());
        return setMeal;
    }
}
